**********************************************************************************************************************************************
*** Replication data for: "Issue engagement across members of parliament: the role of issue specialization and party leadership"           ***
*** Version: 04 August 2020																	                                               ***
*** Authors: Thomas M. Meyer (Humboldt University Berlin) & Markus Wagner (University of Vienna)                                           ***
*** Input-files: data_engagement_month.dta; data_engagement_week.dta;  data_engagement_replacement.dta                      			   ***
*** Output: Tables 1, 2, A.1, B.1 ;   Figures: 1, 2, A.1, A.2, B.1, B.2                                                                    ***
**********************************************************************************************************************************************

*** dependencies ***
capture ssc install estout
version 16.1

*** define directories for data and output ***
global GETDIR "YOUR DATA DIRECTORY"  // e.g. "C:\My files\Data"
global WORKDIR "YOUR WORKING DIRECTORY" // your working directory (e.g. "C:\My files\Output")

*** load data set ***
cd "$WORKDIR"
use "$GETDIR\data_engagement_month.dta", clear



******************************
********* Manuscript *********
******************************

*** Information for Table 1: summary statistics 
sum    W_comm_y W_leader_y man_salience  W_party_y  W_lrdist_y no_of_comm_member    if pr_lag!=.

tab pr if pr_lag!=.
tab pr_lag if pr_lag!=.
tab party_leadership if pr_lag!=.
tab female if pr_lag!=.
tab new_mp if pr_lag!=.



*** Table 2: regression results

* M1: Party issue engagement
* M2: MP issue engagement
* M3: MP issue engagement + controls
* M4: MP issue engagement + controls+ role of MP

* M1
logit pr pr_lag   man_salience                                                             W_party_y  W_lrdist_y no_of_comm_member i.month i.party  , cluster(ind_ID)
estimates store logit_m1
* M2
logit pr pr_lag   man_salience                                     c.W_leader_y  c.W_comm_y  W_party_y  W_lrdist_y no_of_comm_member i.month i.party  , cluster(ind_ID)
estimates store logit_m2
* M3
logit pr pr_lag   man_salience  female i.party_leadership  new_mp  c.W_leader_y  c.W_comm_y  W_party_y  W_lrdist_y no_of_comm_member i.month i.party  , cluster(ind_ID)
estimates store logit_m3
* M4
logit pr pr_lag  man_salience   female             new_mp  c.W_leader_y##i.party_leadership  c.W_comm_y##i.party_leadership                                                                      W_party_y  W_lrdist_y no_of_comm_member i.month i.party  , cluster(ind_ID)
estimates store logit_m4

esttab logit_m1  logit_m2  logit_m3 logit_m4  using "M1-M4.rtf", replace label    ///
						star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
						mtitles("M1" "M2" "M3" "M4") ///
						scalar(ll) nogaps drop(*.month *.party) noomitted  nobaselevels ///
						order(W_comm_y W_leader_y 1.party_leadership 1.party_leadership#c.W_comm_y 1.party_leadership#c.W_leader_y ///
						female new_mp man_salience W_party_y W_lrdist_y no_of_comm_member pr_lag )
				



*** Figure 1: Predicted probability to engage with committee members and party elites (based on M3)

estimates restore logit_m3
margins, at(W_comm_y=(0(2)34) (mean) man_salience                  W_leader_y   W_party_y  W_lrdist_y  no_of_comm_member new_mp=0  party_leadership=0 female=0  month=2 party=1100000 )        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_comm_y if W_comm_y<=34, fintensity(100) color(gs14) width(1) below xscale(range(0 34)) xlabel(0(2)34) ) ///
    legend(off) ///
	xtitle("Other committee members addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement within committee") ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline(.0825672, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plotopts(lpattern(solid) lcolor(black)) ///
	recastci(rarea) ///
	ciopts(fintensity(100) color(gs8))
graph save Fig1_left.gph, replace 

      
margins, at(W_leader_y=(0(1)6) (mean) man_salience W_comm_y                     W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=0 female=0  month=2 party=1100000  )        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_leader_y, fintensity(100) color(gs14) width(1) below xlabel(0(1)6) ylabel(0(0.2)0.8, nogrid)) ///
    legend(off) ///
	xtitle("Other party frontbenchers addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement with party leadership") ///
	xsize(5) ysize(4)  ///
	xlabel(0(1)6) ///	
	yline(.0825672, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plotopts(lpattern(solid) lcolor(black)) ///
	recastci(rarea) ///
	ciopts(fintensity(100) color(gs8))
graph save Fig1_right.gph, replace 
	
graph combine Fig1_left.gph Fig1_right.gph, graphregion(color(white)) xsize(8) ysize(4)
graph export Fig1.tif, replace width(2400)
erase Fig1_left.gph 
erase Fig1_right.gph
	
	

*** Figure 2: Predicted probability of issue engagement depending on party role (based on M4)

estimates restore logit_m4
margins, at(W_comm_y=(0(2)34) (mean) man_salience                 W_leader_y  W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=0 female=0  month=2 party=1100000  )  ///
	     at(W_comm_y=(0(2)34) (mean) man_salience                 W_leader_y  W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=1 female=0  month=2 party=1100000  )         
marginsplot, graphregion(color(white)) ///
	addplot(hist W_comm_y if W_comm_y<=34, fintensity(100) color(gs14) width(1) below xscale(range(0 34)) xlabel(0(2)34) legend(order(3 "Backbench" 4 "Party leadership"))) ///	
	xtitle("Other committee members addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement within committee: Party role") ///
	 ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline(.0825672, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plot1opts(lpattern(solid) lcolor(black)) ///
	plot2opts(lpattern(dash) lcolor(black)) ///
	recastci(rarea) ///
	ci1opts(fintensity(100) color(gs8%30)) ///
	ci2opts(fintensity(100) color(gs12%30)) 
graph save Fig2_left.gph, replace 



margins, at(W_leader_y=(0(1)6) (mean) man_salience W_comm_y                   W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=0 female=0  month=2 party=1100000  )  ///
		 at(W_leader_y=(0(1)6) (mean) man_salience W_comm_y                   W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=1 female=0  month=2 party=1100000  )        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_leader_y, fintensity(100) color(gs14) width(1) below xlabel(0(1)6) ylabel(0(0.2)0.8, nogrid) legend(order(3 "Backbench" 4 "Party leadership")) ) ///	
	xtitle("Other party frontbenchers addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement with party leadership: Party role") ///
	///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline(.0825672, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plot1opts(lpattern(solid) lcolor(black)) ///
	plot2opts(lpattern(dash) lcolor(black)) ///
	recastci(rarea) ///
	ci1opts(fintensity(100) color(gs8%30)) ///
	ci2opts(fintensity(100) color(gs12%30)) 
graph save Fig2_right.gph, replace 

graph combine Fig2_left.gph Fig2_right.gph, graphregion(color(white)) xsize(8) ysize(4)
graph export Fig2.tif, replace width(2400)
erase Fig2_left.gph 
erase Fig2_right.gph
	


********************************************************************************************************
********* Appendix A: Including MPs leaving or entering parliament during the legislative term *********
******************************************************************************************************** 
use "$GETDIR\data_engagement_replacement.dta", clear


*** Table A.1: Explaining issue engagement in the legislature
* M1: Party issue engagement
* M2: MP issue engagement
* M3: MP issue engagement + controls
* M4: MP issue engagement + controls+ role of MP

*M1
logit pr pr_lag   man_salience                                                     W_party_y  W_lrdist_y no_of_comm_member active_mp i.month i.party  , cluster(ind_ID)
estimates store logit_m1_replacement
*M2
logit pr pr_lag   man_salience                                     c.W_leader_y  c.W_comm_y    W_party_y  W_lrdist_y no_of_comm_member active_mp  i.month i.party  , cluster(ind_ID)
estimates store logit_m2_replacement 
*M3
logit pr pr_lag   man_salience  female i.party_leadership  new_mp  c.W_leader_y  c.W_comm_y    W_party_y  W_lrdist_y no_of_comm_member active_mp  i.month i.party  , cluster(ind_ID)
estimates store logit_m3_replacement
* M4
logit pr pr_lag  man_salience female                       new_mp  c.W_leader_y##i.party_leadership  c.W_comm_y##i.party_leadership                                                                      W_party_y  W_lrdist_y no_of_comm_member active_mp i.month i.party  , cluster(ind_ID)
estimates store logit_m4_replacement


esttab logit_m1_replacement  logit_m2_replacement  logit_m3_replacement logit_m4_replacement  using "M1-M4_replacement.rtf", replace label    ///
						star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
						mtitles("M1" "M2" "M3" "M4") ///
						scalar(ll) nogaps drop(*.month *.party) noomitted  nobaselevels ///
						order(W_comm_y W_leader_y 1.party_leadership 1.party_leadership#c.W_comm_y 1.party_leadership#c.W_leader_y ///
						female new_mp man_salience W_party_y W_lrdist_y no_of_comm_member active_mp pr_lag )


*** Figure A.1: Predicted probability to engage with committee members and party elites

estimates restore logit_m3_replacement
margins, at(W_comm_y=(0(2)37) (mean) man_salience                  W_leader_y   W_party_y  W_lrdist_y  no_of_comm_member active_mp=1 new_mp=0  party_leadership=0 female=0  month=2 party=1100000 )        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_comm_y if W_comm_y<=37, fintensity(100) color(gs14) width(1) below xscale(range(0 34)) xlabel(0(2)37) ) ///
    legend(off) ///
	xtitle("Other committee members addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement within committee") ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline( .070814 , lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plotopts(lpattern(solid) lcolor(black)) ///
	recastci(rarea) ///
	ciopts(fintensity(100) color(gs8))
graph export FigA1_left.tif, replace


margins, at(W_leader_y=(0(1)8) (mean) man_salience W_comm_y                     W_party_y  W_lrdist_y no_of_comm_member active_mp=1  new_mp=0  party_leadership=0 female=0  month=2 party=1100000  )        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_leader_y, fintensity(100) color(gs14) width(1) below xlabel(0(1)6) ylabel(0(0.2)0.8, nogrid)) ///
    legend(off) ///
	xtitle("Other party frontbenchers addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement with party leadership") ///
	xsize(5) ysize(4)  ///
	xlabel(0(1)6) ///	
	yline( .070814 , lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plotopts(lpattern(solid) lcolor(black)) ///
	recastci(rarea) ///
	ciopts(fintensity(100) color(gs8))
graph export FigA1_right.tif, replace
	


*** Figure A.2: Predicted probability of issue engagement depending on party role

estimates restore logit_m4_replacement
margins, at(W_comm_y=(0(2)37) (mean) man_salience                 W_leader_y  W_party_y  W_lrdist_y no_of_comm_member active_mp=1 new_mp=0  party_leadership=0 female=0  month=2 party=1100000  )  ///
	     at(W_comm_y=(0(2)37) (mean) man_salience                 W_leader_y  W_party_y  W_lrdist_y no_of_comm_member active_mp=1 new_mp=0  party_leadership=1 female=0  month=2 party=1100000  )         
marginsplot, graphregion(color(white)) ///
	addplot(hist W_comm_y if W_comm_y<=37, fintensity(100) color(gs14) width(1) below xscale(range(0 34)) xlabel(0(2)37) legend(order(3 "Backbench" 4 "Party leadership"))) ///
	xtitle("Other committee members addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement within committee: Party role") ///
	 ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline( .070814 , lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plot1opts(lpattern(solid) lcolor(black)) ///
	plot2opts(lpattern(dash) lcolor(black)) ///
	recastci(rarea) ///
	ci1opts(fintensity(100) color(gs8%30)) ///
	ci2opts(fintensity(100) color(gs12%30)) 
graph export FigA2_left.tif, replace
	


margins, at(W_leader_y=(0(1)8) (mean) man_salience W_comm_y                   W_party_y  W_lrdist_y no_of_comm_member active_mp=1  new_mp=0  party_leadership=0 female=0  month=2 party=1100000  )  ///
		 at(W_leader_y=(0(1)8) (mean) man_salience W_comm_y                   W_party_y  W_lrdist_y no_of_comm_member active_mp=1  new_mp=0  party_leadership=1 female=0  month=2 party=1100000  )        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_leader_y , fintensity(100) color(gs14) width(1) below xlabel(0(1)6) ylabel(0(0.2)0.8, nogrid) legend(order(3 "Backbench" 4 "Party leadership"))) ///
	xtitle("Other party frontbenchers addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement with party leadership: Party role") ///
	 ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline( .070814 , lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plot1opts(lpattern(solid) lcolor(black)) ///
	plot2opts(lpattern(dash) lcolor(black)) ///
	recastci(rarea) ///
	ci1opts(fintensity(100) color(gs8%30)) ///
	ci2opts(fintensity(100) color(gs12%30)) 
graph export FigA2_right.tif, replace




****************************************************************************
********* Appendix B: Analysing issue engagement on a weekly basis *********
****************************************************************************
use "$GETDIR\data_engagement_week.dta", clear


*** Table B.1: Explaining issue engagement in the legislature
* M1: Party issue engagement
* M2: MP issue engagement
* M3: MP issue engagement + controls
* M4: MP issue engagement + controls+ role of MP

*M1
logit pr pr_lag   man_salience                                                             W_party_y  W_lrdist_y no_of_comm_member  i.party  i.month , cluster(ind_ID)
estimates store logit_m1_week
*M2
logit pr pr_lag   man_salience                                     c.W_leader_y  c.W_comm_y    W_party_y  W_lrdist_y no_of_comm_member  i.party i.month , cluster(ind_ID)
estimates store logit_m2_week 
*M3
logit pr pr_lag   man_salience  female i.party_leadership  new_mp  c.W_leader_y  c.W_comm_y    W_party_y  W_lrdist_y no_of_comm_member i.party i.month , cluster(ind_ID)
estimates store logit_m3_week
*M4
logit pr pr_lag  man_salience female                       new_mp  c.W_leader_y##i.party_leadership  c.W_comm_y##i.party_leadership                                                                      W_party_y  W_lrdist_y no_of_comm_member i.party i.month, cluster(ind_ID)
estimates store logit_m4_week


esttab logit_m1_week  logit_m2_week  logit_m3_week logit_m4_week  using "M1-M4_week.rtf", replace label    ///
						star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
						mtitles("M1" "M2" "M3" "M4") ///
						scalar(ll) nogaps drop(*.month *.party) noomitted  nobaselevels ///
						order(W_comm_y W_leader_y 1.party_leadership 1.party_leadership#c.W_comm_y 1.party_leadership#c.W_leader_y ///
						female new_mp man_salience W_party_y W_lrdist_y no_of_comm_member pr_lag )



*** Figure B.1: Predicted probability to engage with committee members and party elites

estimates restore logit_m3
margins, at(W_comm_y=(0(2)20) (mean) man_salience                  W_leader_y   W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=0 female=0  party=1100000 month=2)        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_comm_y if W_comm_y<=20, fintensity(100) color(gs14) width(1) below xscale(range(0 20)) xlabel(0(2)20) ) ///
    legend(off) ///
	xtitle("Other committee members addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement within committee") ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline(.025603, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plotopts(lpattern(solid) lcolor(black)) ///
	recastci(rarea) ///
	ciopts(fintensity(100) color(gs8))
graph export FigB1_left.tif, replace



margins, at(W_leader_y=(0(1)6) (mean) man_salience W_comm_y                     W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=0 female=0  party=1100000 month=2)        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_leader_y, fintensity(100) color(gs14) width(1) below xlabel(0(1)6) ylabel(0(0.2)0.8, nogrid)) ///
    legend(off) ///
	xtitle("Other party frontbenchers addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement with party leadership") ///
	xsize(5) ysize(4)  ///
	xlabel(0(1)6) ///	
	yline(.025603, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plotopts(lpattern(solid)) ///
	recastci(rarea) ///
	ciopts(fintensity(100) color(gs8))
graph export FigB1_right.tif, replace
	


*** Figure B.2: Predicted probability of issue engagement depending on party role

estimates restore logit_m4_week
margins, at(W_comm_y=(0(2)20) (mean) man_salience                 W_leader_y  W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=0 female=0   party=1100000 month=2)  ///
	     at(W_comm_y=(0(2)20) (mean) man_salience                 W_leader_y  W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=1 female=0  party=1100000 month=2)         
marginsplot, graphregion(color(white)) ///
	addplot(hist W_comm_y if W_comm_y<=20, fintensity(100) color(gs14) width(1) below xscale(range(0 20)) xlabel(0(2)20) 	legend(order(3 "Backbench" 4 "Party leadership"))) ///
	xtitle("Other committee members addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement within committee: Party role") ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline(.0256032, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plot1opts(lpattern(solid) lcolor(black)) ///
	plot2opts(lpattern(dash) lcolor(black)) ///
	recastci(rarea) ///
	ci1opts(fintensity(100) color(gs8%30)) ///
	ci2opts(fintensity(100) color(gs12%30)) 
graph export FigB2_left.tif, replace
	


margins, at(W_leader_y=(0(1)6) (mean) man_salience W_comm_y                   W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=0 female=0  party=1100000 month=2)  ///
		 at(W_leader_y=(0(1)6) (mean) man_salience W_comm_y                   W_party_y  W_lrdist_y no_of_comm_member new_mp=0  party_leadership=1 female=0  party=1100000 month=2)        
marginsplot, graphregion(color(white)) ///
	addplot(hist W_leader_y, fintensity(100) color(gs14) width(1) below xlabel(0(1)6) ylabel(0(0.2)0.8, nogrid) legend(order(3 "Backbench" 4 "Party leadership"))) ///
	xtitle("Other party frontbenchers addressing an issue") ///
	ytitle("Probability to issue press releases")  ///
	title("Issue engagement with party leadership: Party role") ///
	xsize(5) ysize(4)  ///
	ylabel(0(0.2)0.8, nogrid) ///
	yline(.025603, lpattern(solid) lcolor(forest_green)) ///
	yline(0, lpattern(solid) lcolor(black)) ///
	recast(line) ///
	plot1opts(lpattern(solid) lcolor(black)) ///
	plot2opts(lpattern(dash) lcolor(black)) ///
	recastci(rarea) ///
	ci1opts(fintensity(100) color(gs8%30)) ///
	ci2opts(fintensity(100) color(gs12%30)) 
graph export FigB2_right.tif, replace	


	



